package com.hqj.consumer.controller;

import com.hqj.consumer.service.UserService;
import com.hqj.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.client.RestTemplate;

import java.util.List;

@Controller
@RequestMapping("/uc")
public class UserController {

    private static final String HTTP_NAME="http://hqj-eureka-client-8002";

    @Autowired
    private RestTemplate rt;

    @Autowired
    private UserService us;

    @GetMapping("/findUser1")
    @ResponseBody
    public List<User> findUser1(){
        String url = HTTP_NAME + "/uc/findUsers";
        return rt.getForObject(url,List.class);
    }

    @GetMapping("/findUser2")
    @ResponseBody
    public List<User> findUser2(){
        return us.findUser();
    }


}
